﻿using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Interop;
using ZhuXingFamilys.ExportExcel;

namespace ZhuXingFamilys.ModelInformation
{
    [Transaction(TransactionMode.Manual)]
    internal class ModelInformationCommand : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;

            ModelInformationWindow window = ModelInformationWindow.GetInstance(uiapp);
            WindowInteropHelper eh = new WindowInteropHelper(window);
            eh.Owner = Process.GetCurrentProcess().MainWindowHandle;
            
            window.Show();
            window.Activate();
            if (window.WindowState == WindowState.Minimized)
            {
                window.WindowState = WindowState.Normal;
            }
            return Result.Succeeded;
        }
    }
}
